package com.mofang.powerdekorhelper.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.mofang.powerdekorhelper.R;
import com.mofang.powerdekorhelper.activity.customer.CustomerDetialActivity;
import com.mofang.powerdekorhelper.base.recycleview.BaseRecycleViewAdapter;
import com.mofang.powerdekorhelper.base.recycleview.BaseViewHolder;
import com.mofang.powerdekorhelper.model.CustomerList;

import java.util.List;

/**
 * Created by luofei on 2017/9/2 0002.
 * 说明：
 */

public class CustomerListAdapter extends BaseRecycleViewAdapter {

    public CustomerListAdapter(List<?> data, Context mContext, int layoutId) {
        super(data, mContext, layoutId);
    }

    @Override
    protected <T> void convert(BaseViewHolder holder, T bean, int position) {

        final CustomerList.Data data = (CustomerList.Data) bean;

        holder.setText(R.id.customer_list_item_name, data.getCustomerName());
        holder.setText(R.id.customer_list_item_phone, data.getCustonerPhone());
        holder.setText(R.id.customer_list_item_order, data.getOrderPrice() + "");

        holder.setOnclickListener(R.id.customer_list_item_detail, new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                mContext.startActivity(new Intent(mContext, CustomerDetialActivity.class)
                        .putExtra("CustomerId", data.getCustomerId()));
            }
        });
    }

    public void addData(List<CustomerList.Data> datas) {
        mData.addAll(datas);
        notifyDataSetChanged();
    }
}
